package acwing.枚举;

import java.util.Scanner;

/**
 * 特别数的和
 *
 * @author yang
 * @date 2021/11/25
 */
public class 特别数的和 {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int res = 0;
        for (int i = 1; i <= n; i++) {
            int t = i;
            while (t != 0) {
                int x = t % 10;
                t /= 10;
                if (x == 1 || x == 2 || x == 9 || x == 10) {
                    res += x;
                    break;
                }
            }
        }
        System.out.println(res);
    }
    /*  字符串装换为数字
        int x = 0
    *   for(int i = 0; i < str.length(); i++) x * 10 + str[i] - '0'
    * */
}
